package br.com.bmb.monitorimoveis.servico.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import br.com.bmb.monitorimoveis.persistencia.IAbstractDAO;
import br.com.bmb.monitorimoveis.servico.IAbstractService;

public abstract class AbstractService<ENTITY, IDTYPE> implements IAbstractService<ENTITY, IDTYPE> {

	@Transactional
	public ENTITY inserir(ENTITY entity) {
		return (ENTITY) getDAO().inserir(entity);
		
	}

	@Transactional
	public void alterar(ENTITY entity) {
		getDAO().alterar(entity);
		
	}

	@Transactional
	public void remover(ENTITY entity) {
		getDAO().remover(entity);
		
	}

	@Transactional
	public ENTITY getById(IDTYPE id) {
		return getDAO().getById(id);
	}

	@Transactional
	public List<ENTITY> listAll() {
		return getDAO().listAll();
	}
	
	protected abstract IAbstractDAO<ENTITY, IDTYPE> getDAO();

}
